<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiVisualWidgetTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_visual_widget';

    /**
     * Run the migrations.
     * @table qii_visual_widget
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('挂件数据ID');
            $table->string('name', 180)->default('')->comment('挂件标识');
            $table->string('type', 50)->default('')->comment('挂件自定义类别(由开发人员自行指定)');
            $table->longText('data')->comment('配置参数(挂件保存的数据 serialize)');
            $table->string('title', 180)->default('')->comment('挂件自定义名称');
            $table->string('tpl', 180)->default('')->comment('挂件模板');
            $table->unsignedInteger('modified')->default('0')->comment('修改时间');

            $table->index(["name", "type"], 'widget_name_type');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
